@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

SET LoadLibraryCompatible=True
SET LoadableByBWAPI=True
SET AIRunnableInStarcraft=False
SET BWAPIFullyMapped=False
SET BWAPIRemappedToDotNetStandards=False
SET BWTAFullyMapped=False
SET BWTARemappedToDotNetStandards=False
SET ReadyForBetaTesting=False
SET BetaTested=False
SET Complete=False

SET /A Major = 0
SET /A Minor = 0

SET BuildConfiguration=Alpha

IF "%LoadLibraryCompatible%" == "True" (
	SET /A Minor = 1
	IF "%LoadableByBWAPI%" == "True" (
		SET /A Minor = 2
		IF "%AIRunnableInStarcraft%" == "True" (
			SET /A Minor = 3
			IF "%BWAPIFullyMapped%" == "True" (
				SET /A Minor = 4
				IF "%BWAPIRemappedToDotNetStandards%" == "True" (
					SET /A Minor = 5
					IF "%BWTAFullyMapped%" == "True" (
						SET /A Minor = 6
						IF "%BWTARemappedToDotNetStandards%" == "True" (
							SET /A Minor = 7
							IF "%ReadyForBetaTesting%" == "True" (
								SET /A Minor = 8
								SET BuildConfiguration=Beta
								IF "%BetaTested%" == "True" (
									SET /A Minor = 9
									SET BuildConfiguration=Release Candidate
									IF "%Complete%" == "True" (
										SET /A Minor = 0
										SET /A Major = 1
										SET BuildConfiguration=Release
									)
								)
							)
						)
					)
				)
			)
		)
	)
)

SET /A Build = 0
FOR /F "tokens=2-4 delims=/ " %%A IN ('DATE /T') DO (
	SET /A Build = "((%%C - 2000) << 12) | (%%B << 8) | %%A"
)

SET /A Revision = 0
FOR /F "tokens=1*" %%R IN ('SVNVERSION ..\') DO (
	SET TMPVER=%%R
	SET TMPVER2=!TMPVER:~0,-1!
	IF "!TMPVER:~-1!" == "M" (
		SET /A Revision = !TMPVER2!
  ) ELSE (
		SET /A Revision = !TMPVER!
	)
)

ECHO #define VersionString "!Major!.!Minor!.!Build!.!Revision!" > Version.h
ECHO #define BuildConfiguration "%BuildConfiguration%" >> Version.h

ENDLOCAL